package com.neusoft.elmboot.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.elmboot.po.Orders;
import com.neusoft.elmboot.service.OrdersService;

@RestController
@RequestMapping("/OrdersController")
public class OrdersController {
	
	@Autowired
	private OrdersService ordersService;
	@RequestMapping("/createOrders")
	public int createOrders(Orders orders) throws Exception{
		return ordersService.createOrders(orders);
	}
	@RequestMapping("/getOrdersById")
	 public Orders getOrdersById(Orders orders) throws Exception{
	 return ordersService.getOrdersById(orders.getOrderId());
	 }
	 
	//order by orderId -> order by orderDate
	 @RequestMapping("/listOrdersByUserId")
	 public List<Orders> listOrdersByUserId(Orders orders) throws Exception{
	 return ordersService.listOrdersByUserId(orders.getUserId());
	 }
	 
	 //返回值：受影响的行数
	 //按照orderId删除，成功为1，失败为0
	 @RequestMapping("/removeOrders")
	 public int removeOrders(Orders orders) throws Exception{
		 return ordersService.removeOrders(orders);
	 }
	 
}